<!DOCTYPE html>
<html>
<head>
    <title>菜单管理</title>
    <script src="/statics/libs/jquery.min.js"></script>
    <script src="/statics/libs/vue.min.js"></script>
    <link rel="stylesheet" href="/statics/plugins/element-ui/lib/theme-chalk/index.css">
    <script src="/statics/plugins/element-ui/lib/index.js"></script>

    <style>
        /*解决Vue刷新一瞬间出现样式未加载完或者出现Vue代码问题*/
        [v-cloak]{
            display: none;
        }
        .el-table__header-wrapper .el-checkbox {
            display: none
        }
    </style>
</head>
<body>
<div id="cwapp" v-cloak>
    <div v-show="showList">

        <el-button-group>
            <el-button type="primary" @click="add">新增</el-button>
            <el-button type="primary" @click="update">修改</el-button>
            <el-button type="danger" @click="del">删除</el-button>
        </el-button-group>
        <el-table
                :data="menuList"
                style="width: 100%;margin-bottom: 20px;"
                row-key="menuId"
                border
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                highlight-current-row
                @current-change="handleCurrentChange">
            <el-table-column
                    prop="menuId"
                    label="菜单id"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="name"
                    label="菜单名称"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="parentName"
                    label="上级菜单">
            </el-table-column>
            <el-table-column
                    prop=""
                    label="图标">
                <template slot-scope="scope">
                    <i :class="scope.row.icon"></i>
                </template>
            </el-table-column>
            <el-table-column
                    prop="type"
                    label="类型">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.type===0">目录</el-tag>
                    <el-tag v-if="scope.row.type===1">菜单</el-tag>
                    <el-tag v-if="scope.row.type===2">按钮</el-tag>
                </template>
            </el-table-column>
            <el-table-column
                    prop="orderNum"
                    label="排序号">
            </el-table-column>
            <el-table-column
                    prop="url"
                    label="菜单URL">
            </el-table-column>
        </el-table>


    </div>

    <div v-show="!showList">
        <el-card class="box-card" v-show="!showList" style="width: 35%">
            <div slot="header" class="clearfix">
                <span>{{title}}</span>
            </div>
            <el-form :model="menu" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="类型" prop="type">
                    <el-radio-group v-model="menu.type">
                        <el-radio v-for="item in menuType" :label="item.id">{{item.name}}</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="菜单名称" prop="name">
                    <el-input v-model="menu.name" auto-complete="new-password"></el-input>
                </el-form-item>
                <el-form-item label="上级菜单" prop="parentName">
                    <el-col :span="12">
                        <el-input readonly v-model.trim="menu.parentName"></el-input>
                    </el-col>
                    <el-col :span="12">
                        <el-popover
                                placement="right"
                                width="400"
                                trigger="click"
                                ref="morePop">
                            <el-tree :data="selectMenuList" highlight-current="true" node-key="menuId" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
                            <div style="text-align: right; margin: 0">
                                <el-button size="mini" type="text" @click="closePopover(false)">取消</el-button>
                                <el-button type="primary" size="mini" @click="closePopover(true)">确定</el-button>
                            </div>
                            <el-button slot="reference">选择上级菜单</el-button>
                        </el-popover>
                    </el-col>
                </el-form-item>
                <el-form-item label="菜单URL" prop="url" v-if="menu.type===1">
                    <el-input v-model="menu.url"></el-input>
                </el-form-item>
                <el-form-item label="授权标志" prop="perms" v-if="menu.type === 1 || menu.type === 2">
                    <el-input v-model="menu.perms" aria-placeholder="多个用逗号分隔，如：user:list,user:create"></el-input>
                </el-form-item>
                <el-form-item label="菜单图标" prop="icon" v-if="menu.type !== 2">
                    <el-input v-model="menu.icon"></el-input>
                    <code style="margin-top:4px;display: block;">获取图标：https://element.eleme.cn/#/zh-CN/component/icon</code>
                </el-form-item>
                <el-form-item label="排序" prop="orderNum" v-if="menu.type !== 2">
                    <el-input v-model="menu.orderNum"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="saveOrUpdate">确定</el-button>
                    <el-button @click="getMenuList(false)">返回</el-button>
                </el-form-item>
            </el-form>
        </el-card>


    </div>
</div>
<!-- 选择菜单 -->
<div id="menuLayer" style="display: none;padding:10px;">
    <ul id="menuTree" class="ztree"></ul>
</div>
<script src="/statics/js/modules/sys/menu.js?_${.now?long}"></script>
</body>
</html>
